package com.example.rfidserver.ticket.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.rfidserver.R;
import com.example.rfidserver.pojo.Ticket;
import com.example.rfidserver.pojo.User;

import java.util.List;

public class TicketSubAdapter extends BaseAdapter {
    private List<Ticket> tickets;
    private Context context;
    public TicketSubAdapter(Context context,List<Ticket> tickets){
        super();
        this.tickets = tickets;
        this.context = context;
    }

    @Override
    public int getCount() {
        return tickets.size()==0?0:tickets.size();
    }

    @Override
    public Ticket getItem(int position) {
        return tickets.get(position)==null?null:tickets.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //膨胀器?
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.item_ticket,null);
        final TextView ticket_id_ticket_id = view.findViewById(R.id.ticket_id_ticket);
        final TextView ticket_type_ticket_id = view.findViewById(R.id.ticket_type_ticket);
        final TextView ticket_description_ticket_id = view.findViewById(R.id.ticket_description_ticket);
        ticket_id_ticket_id.setText("门票id:"+getItem(position).getTicket_id());
        ticket_type_ticket_id.setText("门票类型:"+getItem(position).getTicket_type());
        ticket_description_ticket_id.setText("门票描述:"+getItem(position).getTicket_description());
        return view;
    }





}
